<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
  <title>实验室列表</title>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
</head>
<body>
<%@ include file="../header.jsp" %>
<div class="container">
  <h2>实验室列表</h2>
  <%--<div class="search-container">
    <form action="${pageContext.request.contextPath}/labs" method="post">
      <input type="hidden" name="action" value="search">
      <input type="text" name="keyword" placeholder="搜索实验室名称或位置"
             value="${fn:escapeXml(keyword)}">
      <button type="submit">搜索</button>
    </form>
  </div>--%>
  <a href="${pageContext.request.contextPath}/jsp/lab/add.jsp" class="add-btn">添加实验室</a>
  <table class="user-table">
    <thead>
    <tr>
      <th>ID</th>
      <th>实验室名称</th>
      <th>位置</th>
      <th>容量</th>
      <th>设备</th>
      <th>可用时间</th>
      <th>描述</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${labs}" var="lab">
      <tr>
        <td>${lab.labId}</td>
        <td>${lab.labName}</td>
        <td>${lab.location}</td>
        <td>${lab.capacity}</td>
        <td>${lab.equipment}</td>
        <td>${lab.availableTime}</td>
        <td>${lab.description}</td>
        <td>
          <a href="${pageContext.request.contextPath}/labs?action=edit&id=${lab.labId}">编辑</a>
          <a href="${pageContext.request.contextPath}/labs?action=delete&id=${lab.labId}" onclick="return confirm('确定要删除吗?')">删除</a>
        </td>
      </tr>
    </c:forEach>
    </tbody>
  </table>
</div>
</body>
</html>